package contestseeker.visitors;

import org.htmlparser.Tag;
import org.htmlparser.tags.TableColumn;
import org.htmlparser.tags.TableRow;
import org.htmlparser.tags.TableTag;


/**
 * SGU
 * @author rush
 *
 */
public class SGU extends VisitorBase {
	public static final String NAME = "SGU";
	public static final String URL = "http://acm.sgu.ru/contests.php";
	public static final String ENCODING = "windows-1251";
	public static final String TITLE = "Saratov State University :: Online Contester";

	public SGU() {
		super.URL = URL;
		super.ENCODING = ENCODING;
		super.TITLE = TITLE;
		super.NAME = NAME;
	}
	
	@Override
	public void visitTag(Tag tag)
	{
		if (tag instanceof TableTag)
		{
			TableTag table = (TableTag)tag;
			if (table.getAttribute("align") != null && table.getAttribute("width") != null)
			{
				TableRow row;
				TableColumn columns[];
				
				this.beginTable(TITLE);
				this.addHeader(table.getRow(0));
				for (int i = 1; i < table.getRowCount(); ++i)
				{
					row = table.getRow(i);
					columns = row.getColumns();
					if (columns.length == 5)
						this.addColumns(columns);
				}
				this.endTable();
			}
		}
	}
}
